package blow.sky.quoted.entity;

/**
 * @Description 用户表
 * @Author 孙焰明
 * @Date 2021/5/20 10:35
 */

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.codec.digest.DigestUtils;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;

@Entity
@Data
@NoArgsConstructor
@JsonAutoDetect(fieldVisibility=JsonAutoDetect.Visibility.ANY, getterVisibility=JsonAutoDetect.Visibility.NONE)
public class QuoteUser
{
	// 登录邮件
	@Id
	@Email(message = "邮箱格式错误")
	String email;
	// 登录密码
	@NotBlank(message = "密码不能为空")
	String password;

	public QuoteUser(String email, String password)
	{
		this.email = email;
		this.setPassword(password);
	}

	public void setPassword(String password)
	{
		// 密码加密处理
		this.password = DigestUtils.sha256Hex(password);
	}
}
